#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch) && ch != EOF) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1010;

set < int > G[N];
int n, K, w0;
int dis[N][N], x[N], y[N], u[N], v[N];
int ax[N], ay[N], nowans;

void transans() {
	rep(i, 1, K) ax[i] = x[i], ay[i] = y[i];
}

void bakans() {
	rep(i, 1, K) {
		x[i] = ax[i]; y[i] = ay[i];
	}
}

void output() {
	freopen("road.out", "w", stdout);
	rep(i, 1, K) printf("%d %d\n", ax[i], ay[i]);
}

void get(int *dis, int x) {
	queue < int > q; q.push(x); rep(i, 1, n) dis[i] = n + 100;
	dis[x] = 0; q.push(x);
	while(q.size()) {
		int x = q.front(); q.pop();
		for(auto y : G[x]) {
			if(dis[y] > dis[x] + 1) {
				dis[y] = dis[x] + 1;
				q.push(y);
			}
		}
	}
}

int calc() {
	int res = 0;
	rep(i, 1, n) G[i].clear();
	rep(i, 1, K) G[x[i]].insert(y[i]), G[y[i]].insert(x[i]);
	rep(i, 2, n) G[u[i]].insert(v[i]), G[v[i]].insert(u[i]);
	rep(i, 1, n) {
		get(dis[i], i);
		rep(j, 1, n) res += dis[i][j];
	} res /= 2; if(res < nowans) transans(), nowans = res; return res;
}

mt19937 rnd(time(NULL));

const db eps = 1e-14;

int cnt = 0;

db Rand() { return db(rnd() % 1000000007) / 1000000007; }

void simulateAl(db T, db del) {
	//	cerr << Rand() << endl;
	cnt++; bakans(); int lst = calc();
	while(T > eps) {
		int id = rnd() % K + 1;
		int b = rnd() % n + 1, a = y[id];

		y[id] = b; 
		int tres = calc(), delta = tres - lst;
			
		if(tres < lst || exp(-delta / T) > Rand()) lst = tres;
		else {
			y[id] = a;
		}
		T *= del;
	}
	output(), cerr << nowans << " " << cnt << endl;
}

int main() {
    n = in, K = in, w0 = in;
	rep(i, 2, n) u[i] = in, v[i] = in;

	cerr << "!" << endl;
	/*
	rep(i, 1, K) {
		x[i] = in, y[i] = in;
		if(x[i] && y[i]) G[x[i]].insert(y[i]), G[y[i]].insert(x[i]);
	}
	*/
	cerr << "!" << endl;
	
	x[0] = rnd() % n + 1; rep(i, 1, K) x[i] = x[i - 1];
	rep(i, 1, K) y[i] = rnd() % n + 1;

	transans(); nowans = calc(); cerr << nowans << endl;
	while(nowans > w0) {
		simulateAl(100000000000000.00, 0.974);
		simulateAl(1000000000000.00, 0.912);
		simulateAl(10000000000.00, 0.942);
		//simulateAl(1000000.00, 0.95);
		//simulateAl(100000.00, 0.985);
		//simulateAl(100000.00, 0.975);
		simulateAl(100000000.00, 0.925);
		simulateAl(10000000000000.00, 0.993);
		//		simulateAl(10000.00, 0.9975);
	}
}
